<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>history</title>
</head>
<body>
<script>
    // window.location.hash //hash 模式
    // window.history
    // go forward back pushState replaceState
   const btn =  document.createElement('button')
   const txt = document.createTextNode('click')
   btn.appendChild(txt)
   document.documentElement.appendChild(btn)
   btn.addEventListener('click', () =>{
       console.log('click')
       window.history.go(1)
       window.history.back()
       window.history.forward()
       // 这里的url必须得是同源的， 否则会报错的
       window.history.pushState({name:11},'name','https://www.baidu.com')
       // window.history.replaceState()
   })
</script>
</body>
</html>
